//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "tools\fn_dirTo.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_pos1","_pos2","_ret"];
DEFAULT_PARAM(_pos1,0,[]);
DEFAULT_PARAM(_pos2,1,[]);
DEFAULT_PARAM(_ret,1,-1);
if (IS_OBJECT(_pos1)) then {_pos1 = getpos _pos1};
if (IS_OBJECT(_pos2)) then {_pos2 = getpos _pos2};

if (count _pos1 == 3 && count _pos2 == 3) then {
	_ret = ((_pos2 select 0) - (_pos1 select 0)) atan2 ((_pos2 select 1) - (_pos1 select 1));
	if (_ret < 0) then {_ret = _ret + 360};
};
TRACE_1("End",_ret);
TMFPROFILERSTOP;
_ret